package com.itheima02.one_to_many;

import com.itheima.bean.Student;
import com.itheima02.bean.Classes;
import com.itheima02.utils.MyBatisUtils;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import java.util.List;

public class Test02 {

    @Test
    public void findAll(){
        SqlSession sqlSession = MyBatisUtils.getSqlSession();
        ClassesMapper mapper = sqlSession.getMapper(ClassesMapper.class);
        List<Classes> list = mapper.findAll();
        for (Classes cl : list) {
            System.out.println(cl.getId()+","+cl.getName());
            List<Student> students = cl.getStudents();
            for (Student student : students) {
                System.out.println(student);
            }
        }
    }
}
